package com.cnunicom.modules.tra.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.cnunicom.common.utils.AccessTokenUtil;
import com.cnunicom.common.utils.DateUtils;
import com.cnunicom.common.utils.QRCodeUtils;
import com.cnunicom.common.utils.R;
import com.cnunicom.common.websocket.WebSocketServer;
import com.cnunicom.modules.tra.entity.MemberEntity;
import com.cnunicom.modules.tra.service.HomeService;
import com.cnunicom.modules.tra.service.MemberService;
import com.cnunicom.modules.tra.vo.HomeVO;
import me.chanjar.weixin.common.error.WxErrorException;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.time.*;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * @Author: dingziyuan
 * @Date: 2020/1/29/029 21:14
 * @Description: 首页请求控制器
 */
@RestController
@RequestMapping("tra/home")
public class HomeController {

    @Resource
    private HomeService homeService;


    @RequestMapping("/list")
    public R list() {
        HomeVO homeVO = homeService.list();
        return R.ok().put("homeVO",homeVO);

    }

    @RequestMapping("/chart")
    public R chart(@RequestParam Map<String, String> params) {
        String startDate = params.get("startDate");
        String endDate = params.get("endDate");
        HomeVO chartVO = homeService.chart(startDate,endDate,new HomeVO());
        return R.ok().put("chartVO",chartVO);
    }

}
